package com.main.util.template;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.main.tabletobean.ColumnModel;
import com.main.tabletobean.MyFreeMarkTemplate;

import freemarker.template.Template;
import freemarker.template.TemplateException;

public class ServiceTemplateUtil {
    
	private Logger log=LoggerFactory.getLogger(this.getClass());
	public String getServiceTemplate(MyFreeMarkTemplate mfmt){
		try {
			//构造填充数据的Map 
			Map map = new HashMap(); 
			map.put("servicePackage",mfmt.getPackageService());
			map.put("impBeanPackage", mfmt.getPackageBean()+"."+mfmt.getBeanName()); 
			map.put("impDaoPackage", mfmt.getPackageDao()+"."+mfmt.getDaoName()); 
			map.put("serviceAnoName", mfmt.getAnoService());
			map.put("serviceName", mfmt.getServiceName());
			map.put("daoName", mfmt.getDaoName()); 
			map.put("beanName", mfmt.getBeanName());
			Template t = TemplateUtil.getTemplateUtil().getCfg().getTemplate("service.ftl");
			 Writer out = new StringWriter(2048); 
			t.process(map, out);
			return out.toString();
		} catch (IOException | TemplateException e) {
			log.error("加载service模板出错",e);
		} 
		return "";
	}

     public static void main(String[] args) throws Exception { 
     } 
}
